var btn = $("#btn")


function load(a,b,c,d) {
    let options = {
          url : "http://127.0.0.1:8888/users/register",
          type : "POST",
          data: {
                username:a,
                password:b,
                rpassword:c,
                nickname:d
          },
          headers:{
            "Content-Type":"application/x-www-form-urlencoded"
        },
          dataType : "json"
    }
    return  $.ajax(options);
}
btn.on("click",function(){
    var username = $("#username").val()
    var password = $("#password").val()
    var rpassword = $("#rpassword").val()
    var nickname = $("#nickname").val()
    load(username,password,rpassword,nickname)
    .done(function(data){
        console.log(data);
        if(data.code === 1){
            alert(data.message)
            setTimeout(function(){
                location.href = "./login.html"
            },1000)
            
        }else{
            alert(data.message)
        }
    })
})